home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / GNU / emacs.inst / emacs19.idb / usr / gnu / info / emacs-11.z / emacs-11
Encoding:
GNU Info File  |  1994-08-02  |  46.8 KB  |  1,155 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.54 from the
  2. input file emacs.texi.
  3.  
  4. 
  5. File: emacs,  Node: Combining in Emerge,  Next: Fine Points of Emerge,  Prev: Exiting Emerge,  Up: Emerge
  6.  
  7. Combining the Two Versions
  8. --------------------------
  9.  
  10.    Sometimes you want to keep *both* alternatives for a particular
  11. locus.  To do this, use `x c', which edits the merge buffer like this:
  12.  
  13.      #ifdef NEW
  14.      VERSION FROM A FILE
  15.      #else /* NEW */
  16.      VERSION FROM B FILE
  17.      #endif /* NEW */
  18.  
  19. While this example shows C preprocessor conditionals delimiting the two
  20. alternative versions, you can specify the strings you want by setting
  21. the variable `emerge-combine-versions-template' to a string of your
  22. choice.  In the string, `%a' says where to put version A, and `%b' says
  23. where to put version B.  The default setting, which produces the
  24. results shown above, looks like this:
  25.  
  26.      "#ifdef NEW\n%a#else /* NEW */\n%b#endif /* NEW */\n"
  27.  
  28. 
  29. File: emacs,  Node: Fine Points of Emerge,  Prev: Combining in Emerge,  Up: Emerge
  30.  
  31. Fine Points of Emerge
  32. ---------------------
  33.  
  34.    During the merge, you mustn't try to edit the A and B buffers
  35. yourself.  Emerge modifies them temporarily, but ultimately puts them
  36. back the way they were.
  37.  
  38.    You can have any number of merges going at once--just don't use any
  39. one buffer as input to more than one merge at once, since the temporary
  40. changes made in these buffers would get in each other's way.
  41.  
  42.    Starting Emerge can take a long time because it needs to compare the
  43. files fully.  Emacs can't do anything else until `diff' finishes.
  44. Perhaps in the future someone will change Emerge to do the comparison in
  45. the background when the input files are large--then you could keep on
  46. doing other things with Emacs until Emerge gets ready to accept
  47. commands.
  48.  
  49.    After setting up the merge, Emerge runs the hook
  50. `emerge-startup-hook' (*note Hooks::.).
  51.  
  52. 
  53. File: emacs,  Node: C Mode,  Next: Fortran,  Prev: Emerge,  Up: Programs
  54.  
  55. C Mode
  56. ======
  57.  
  58.    In addition to the facilities of typical programming language major
  59. modes (*note Program Modes::.), C mode has various special facilities.
  60.  
  61. `M-a'
  62. `M-e'
  63.      In C mode, `M-a' and `M-e' now move by complete C statements
  64.      (`c-beginning-of-statement' and `c-end-of-statement').  These
  65.      commands do ordinary, textual sentence motion when in or next to a
  66.      comment.
  67.  
  68. `M-q'
  69.      `M-q' in C mode runs `c-fill-paragraph', which is designed for
  70.      filling C comments.  (We assume you don't want to fill the actual
  71.      C code in a C program.)
  72.  
  73. `C-c C-u'
  74.      Move back to the containing preprocessor conditional, setting the
  75.      mark at the starting point (`c-up-conditional').
  76.  
  77.      A prefix argument acts as a repeat count.  With a negative
  78.      argument, this command moves forward to the end of the containing
  79.      preprocessor conditional.  When going backwards, `#elif' acts like
  80.      `#else' followed by `#if'.  When going forwards, `#elif' is
  81.      ignored.
  82.  
  83. `C-c C-n'
  84.      Move forward across the next preprocessor conditional, setting the
  85.      mark at the starting point (`c-forward-conditional').
  86.  
  87. `C-c C-p'
  88.      Move backward across the previous preprocessor conditional,
  89.      setting the at the starting point (`c-backward-conditional').
  90.  
  91. `M-x c-macro-expand'
  92.      When you are debugging C code that uses macros, sometimes it is
  93.      hard to figure out precisely how the macros expand.  The command
  94.      `M-x c-macro-expand' runs the C preprocessor and shows you what
  95.      expansion results from the region.  The portion of the buffer
  96.      before the region is also included in preprocessing, for the sake
  97.      of macros defined there, but the output from this part isn't shown.
  98.  
  99. `M-x c-backslash-region'
  100.      Insert or align `\' characters at the ends of the lines of the
  101.      region, except for the last such line.  This is useful after
  102.      writing or editing a C macro definition.
  103.  
  104.      If a line already ends in `\', this command adjusts the amount of
  105.      whitespace before it.  Otherwise, it inserts a new `\'.
  106.  
  107.    C++ mode is like C mode, except that it understands C++ comment
  108. syntax and certain other differences between C and C++.  It also has a
  109. command `M-x fill-c++-comment', which fills a paragraph made of C++
  110. comment lines.
  111.  
  112.    The command `comment-region' is useful in C++ mode for commenting
  113. out several consecutive lines, or removing the commenting out of such
  114. lines.  (You don't need this command with C comment syntax because you
  115. don't need to put comment delimiters on each line.)  *Note Comments::.
  116.  
  117. 
  118. File: emacs,  Node: Fortran,  Next: Asm Mode,  Prev: C Mode,  Up: Programs
  119.  
  120. Fortran Mode
  121. ============
  122.  
  123.    Fortran mode provides special motion commands for Fortran statements
  124. and subprograms, and indentation commands that understand Fortran
  125. conventions of nesting, line numbers and continuation statements.
  126. Fortran mode has it's own Auto Fill mode that breaks long lines into
  127. proper Fortran continuation lines.
  128.  
  129.    Special commands for comments are provided because Fortran comments
  130. are unlike those of other languages.
  131.  
  132.    Built-in abbrevs optionally save typing when you insert Fortran
  133. keywords.
  134.  
  135.    Use `M-x fortran-mode' to switch to this major mode.  This command
  136. runs the hook `fortran-mode-hook' (*note Hooks::.).
  137.  
  138. * Menu:
  139.  
  140. * Motion: Fortran Motion.      Moving point by statements or subprograms.
  141. * Indent: Fortran Indent.      Indentation commands for Fortran.
  142. * Comments: Fortran Comments.  Inserting and aligning comments.
  143. * Autofill: Fortran Autofill.  Auto fill minor mode for Fortran.
  144. * Columns: Fortran Columns.    Measuring columns for valid Fortran.
  145. * Abbrev: Fortran Abbrev.      Built-in abbrevs for Fortran keywords.
  146.  
  147.    Fortran mode was contributed by Michael Prange.  It has been updated
  148. by Stephen A. Wood who has collated the contributions and suggestions
  149. of many users.
  150.  
  151. 
  152. File: emacs,  Node: Fortran Motion,  Next: Fortran Indent,  Up: Fortran
  153.  
  154. Motion Commands
  155. ---------------
  156.  
  157.    Fortran mode provides special commands to move by subprograms
  158. (functions and subroutines) and by statements.  There is also a command
  159. to put the region around one subprogram, convenient for killing it or
  160. moving it.
  161.  
  162. `C-M-a'
  163.      Move to beginning of subprogram
  164.      (`beginning-of-fortran-subprogram').
  165.  
  166. `C-M-e'
  167.      Move to end of subprogram (`end-of-fortran-subprogram').
  168.  
  169. `C-M-h'
  170.      Put point at beginning of subprogram and mark at end
  171.      (`mark-fortran-subprogram').
  172.  
  173. `C-c C-n'
  174.      Move to beginning of current or next statement
  175.      (`fortran-next-statement').
  176.  
  177. `C-c C-p'
  178.      Move to beginning of current or previous statement
  179.      (`fortran-previous-statement').
  180.  
  181. 
  182. File: emacs,  Node: Fortran Indent,  Next: Fortran Comments,  Prev: Fortran Motion,  Up: Fortran
  183.  
  184. Fortran Indentation
  185. -------------------
  186.  
  187.    Special commands and features are needed for indenting Fortran code
  188. in order to make sure various syntactic entities (line numbers, comment
  189. line indicators and continuation line flags) appear in the columns that
  190. are required for standard Fortran.
  191.  
  192. * Menu:
  193.  
  194. * Commands: ForIndent Commands.  Commands for indenting Fortran.
  195. * Contline: ForIndent Cont.      How continuation lines indent.
  196. * Numbers:  ForIndent Num.       How line numbers auto-indent.
  197. * Conv:     ForIndent Conv.      Conventions you must obey to avoid trouble.
  198. * Vars:     ForIndent Vars.      Variables controlling Fortran indent style.
  199.  
  200. 
  201. File: emacs,  Node: ForIndent Commands,  Next: ForIndent Cont,  Up: Fortran Indent
  202.  
  203. Fortran Indentation Commands
  204. ............................
  205.  
  206. `TAB'
  207.      Indent the current line (`fortran-indent-line').
  208.  
  209. `LFD'
  210.      Indent the current and start a new indented line
  211.      (`fortran-indent-new-line').
  212.  
  213. `M-LFD'
  214.      Break the current line and set up a continuation line.
  215.  
  216. `C-M-q'
  217.      Indent all the lines of the subprogram point is in
  218.      (`fortran-indent-subprogram').
  219.  
  220.    Fortran mode redefines TAB to reindent the current line for Fortran
  221. (`fortran-indent-line').  This command indents Line numbers and
  222. continuation markers to their required columns, and independently
  223. indents the body of the statement based on its nesting in the program.
  224.  
  225.    The key `LFD' runs the command `fortran-indent-new-line', which
  226. reindents the current line then makes and indents a new line.  This
  227. command is useful to reindent the closing statement of `do' loops and
  228. other blocks before starting a new line.
  229.  
  230.    The key `C-M-q' runs `fortran-indent-subprogram', a command to
  231. reindent all the lines of the Fortran subprogram (function or
  232. subroutine) containing point.
  233.  
  234.    The key `M-LFD' runs `fortran-split-line', which splits a line in
  235. the appropriate fashion for Fortran.  In a non-comment line, the second
  236. half becomes a continuation line and is indented accordingly.  In a
  237. comment line, both halves become separate comment lines.
  238.  
  239. 
  240. File: emacs,  Node: ForIndent Cont,  Next: ForIndent Num,  Prev: ForIndent Commands,  Up: Fortran Indent
  241.  
  242. Continuation Lines
  243. ..................
  244.  
  245.    Most modern Fortran compilers allow two ways of writing continuation
  246. lines.  If the first non-space character on a line is in column 5, then
  247. that line is a continuation of the previous line.  We call this "fixed
  248. format".  (In GNU Emacs we always count columns from 0.)  A line that
  249. starts with a tab character followed by any digit except `0' is also a
  250. continuation line.  We call this style of continuation "tab format".
  251.  
  252.    Fortran mode can make either style of continuation line, but you
  253. must specify which one you prefer.  The value of the variable
  254. `indent-tabs-mode' controls the choice: `nil' for fixed format, and
  255. non-`nil' for tab format.  You can tell which style is presently in
  256. effect by the presence or absence of the string `Tab' in the mode line.
  257.  
  258.    If the text on a line starts with the conventional Fortran
  259. continuation marker `$', or if it begins with any non-whitespace
  260. character in column 5, Fortran mode treats it as a continuation line.
  261. When you indent a continuation line with TAB, it converts the line to
  262. the current continuation style.  When you split a Fortran statement
  263. with `M-LFD', the continuation marker on the newline is created
  264. according to the continuation style.
  265.  
  266.    The setting of continuation style affects several other aspects of
  267. editing in Fortran mode.  In fixed format mode, the minimum column
  268. number for the body of a statement is 6.  Lines inside of Fortran
  269. blocks that are indented to larger column numbers always use only the
  270. space character for whitespace.  In tab format mode, the minimum column
  271. number for the statement body is 8, and the whitespace before column 8
  272. must always consist of one tab character.
  273.  
  274.    When you enter Fortran mode for an existing file, it tries to deduce
  275. the proper continuation style automatically from the file contents.
  276. The first line that begins with either a tab character or six spaces
  277. determines the choice.  The variable `fortran-analyze-depth' specifies
  278. how many lines to consider (at the beginning of the file); if none of
  279. those lines indicates a style, then the variable
  280. `fortran-tab-mode-default' specifies the style.  If it is `nil', that
  281. specifies fixed format, and non-`nil' specifies tab format.
  282.  
  283. 
  284. File: emacs,  Node: ForIndent Num,  Next: ForIndent Conv,  Prev: ForIndent Cont,  Up: Fortran Indent
  285.  
  286. Line Numbers
  287. ............
  288.  
  289.    If a number is the first non-whitespace in the line, Fortran
  290. indentation assumes it is a line number and moves it to columns 0
  291. through 4.  (Columns always count from 0 in GNU Emacs.)
  292.  
  293.    Line numbers of four digits or less are normally indented one space.
  294. The variable `fortran-line-number-indent' controls this; it specifies
  295. the maximum indentation a line number can have.  Line numbers are
  296. indented to right-justify them to end in column 4 unless that would
  297. require more than this maximum indentation.  The default value of the
  298. variable is 1.
  299.  
  300.    Simply inserting a line number is enough to indent it according to
  301. these rules.  As each digit is inserted, the indentation is recomputed.
  302. To turn off this feature, set the variable
  303. `fortran-electric-line-number' to `nil'.  Then inserting line numbers
  304. is like inserting anything else.
  305.  
  306. 
  307. File: emacs,  Node: ForIndent Conv,  Next: ForIndent Vars,  Prev: ForIndent Num,  Up: Fortran Indent
  308.  
  309. Syntactic Conventions
  310. .....................
  311.  
  312.    Fortran mode assumes that you follow certain conventions that
  313. simplify the task of understanding a Fortran program well enough to
  314. indent it properly:
  315.  
  316.    * Two nested `do' loops never share a `continue' statement.
  317.  
  318.    * Fortran keywords such as `if', `else', `then', `do' and others are
  319.      written without embedded whitespace or line breaks.
  320.  
  321.      Fortran compilers generally ignore whitespace outside of string
  322.      constants, but Fortran mode does not recognize these keywords if
  323.      they are not contiguous.  Constructs such as `else if' or `end do'
  324.      are acceptable, but the second word should be on the same line as
  325.      the first and not on a continuation line.
  326.  
  327. If you fail to follow these conventions, the indentation commands may
  328. indent some lines unaesthetically.  However, a correct Fortran program
  329. retains its meaning when reindented even if the conventions are not
  330. followed.
  331.  
  332. 
  333. File: emacs,  Node: ForIndent Vars,  Prev: ForIndent Conv,  Up: Fortran Indent
  334.  
  335. Variables for Fortran Indentation
  336. .................................
  337.  
  338.    Several additional variables control how Fortran indentation works:
  339.  
  340. `fortran-do-indent'
  341.      Extra indentation within each level of `do' statement (default 3).
  342.  
  343. `fortran-if-indent'
  344.      Extra indentation within each level of `if' statement (default 3).
  345.      This value is also used for extra indentation within each level of
  346.      the Fortran 90 `where' statement.
  347.  
  348. `fortran-structure-indent'
  349.      Extra indentation within each level of `structure', `union', or
  350.      `map' statements (default 3).
  351.  
  352. `fortran-continuation-indent'
  353.      Extra indentation for bodies of continuation lines (default 5).
  354.  
  355. `fortran-check-all-num-for-matching-do'
  356.      If this is `nil', indentation assumes that each `do' statement
  357.      ends on a `continue' statement.  Therefore, when computing
  358.      indentation for a statement other than `continue', it can save time
  359.      by not checking for a `do' statement ending there.  If this is
  360.      non-`nil', indenting any numbered statement must check for a `do'
  361.      that ends there.  The default is `nil'.
  362.  
  363. `fortran-blink-matching-if'
  364.      If this is `t', indenting an `endif' statement moves the cursor
  365.      momentarily to the matching `if' statement to show where it is.
  366.      The default is `nil'.
  367.  
  368. `fortran-minimum-statement-indent-fixed'
  369.      Minimum indentation for fortran statements when using fixed format
  370.      continuation line style.  Statement bodies are never indented less
  371.      than this much.  The default is 6.
  372.  
  373. `fortran-minimum-statement-indent-tab'
  374.      Minimum indentation for fortran statements for tab format
  375.      continuation line style.  Statement bodies are never indented less
  376.      than this much.  The default is 8.
  377.  
  378. 
  379. File: emacs,  Node: Fortran Comments,  Next: Fortran Autofill,  Prev: Fortran Indent,  Up: Fortran
  380.  
  381. Comments
  382. --------
  383.  
  384.    The usual Emacs comment commands assume that a comment can follow a
  385. line of code.  In Fortran, the standard comment syntax requires an
  386. entire line to be just a comment.  Therefore, Fortran mode replaces the
  387. standard Emacs comment commands and defines some new variables.
  388.  
  389.    Fortran mode can also handle a nonstandard comment syntax where
  390. comments start with `!' and can follow other text.  Because only some
  391. Fortran compilers accept this syntax, Fortran mode will not insert such
  392. comments unless you have said in advance to do so.  To do this, set the
  393. variable `comment-start' to `"!"' (*note Variables::.).
  394.  
  395. `M-;'
  396.      Align comment or insert new comment (`fortran-comment-indent').
  397.  
  398. `C-x ;'
  399.      Applies to nonstandard `!' comments only.
  400.  
  401. `C-c ;'
  402.      Turn all lines of the region into comments, or (with argument)
  403.      turn them back into real code (`fortran-comment-region').
  404.  
  405.    `M-;' in Fortran mode is redefined as the command
  406. `fortran-comment-indent'.  Like the usual `M-;' command, this
  407. recognizes any kind of existing comment and aligns its text
  408. appropriately; if there is no existing comment, a comment is inserted
  409. and aligned.  But inserting and aligning comments are not the same in
  410. Fortran mode as in other modes.
  411.  
  412.    When a new comment must be inserted, if the current line is blank, a
  413. full-line comment is inserted.  On a non-blank line, a nonstandard `!'
  414. comment is inserted if you have said you want to use them.  Otherwise a
  415. full-line comment is inserted on a new line before the current line.
  416.  
  417.    Nonstandard `!' comments are aligned like comments in other
  418. languages, but full-line comments are different.  In a standard
  419. full-line comment, the comment delimiter itself must always appear in
  420. column zero.  What can be aligned is the text within the comment.  You
  421. can choose from three styles of alignment by setting the variable
  422. `fortran-comment-indent-style' to one of these values:
  423.  
  424. `fixed'
  425.      Align the text at a fixed column, which is the sum of
  426.      `fortran-comment-line-extra-indent' and the minimum statement
  427.      indentation.  This is the default.
  428.  
  429.      The minimum statement indentation is
  430.      `fortran-minimum-statement-indent-fixed' for fixed format
  431.      continuation line style and `fortran-minimum-statement-indent-tab'
  432.      for tab format style.
  433.  
  434. `relative'
  435.      Align the text as if it were a line of code, but with an additional
  436.      `fortran-comment-line-extra-indent' columns of indentation.
  437.  
  438. `nil'
  439.      Don't move text in full-line columns automatically at all.
  440.  
  441.    In addition, you can specify the character to be used to indent
  442. within full-line comments by setting the variable
  443. `fortran-comment-indent-char' to the single-character string you want
  444. to use.
  445.  
  446.    Fortran mode introduces two variables `comment-line-start' and
  447. `comment-line-start-skip' which play for full-line comments the same
  448. roles played by `comment-start' and `comment-start-skip' for ordinary
  449. text-following comments.  Normally these are set properly by Fortran
  450. mode so you do not need to change them.
  451.  
  452.    The normal Emacs comment command `C-x ;' has not been redefined.  If
  453. you use `!' comments, this command can be used with them.  Otherwise it
  454. is useless in Fortran mode.
  455.  
  456.    The command `C-c ;' (`fortran-comment-region') turns all the lines
  457. of the region into comments by inserting the string `C$$$' at the front
  458. of each one.  With a numeric argument, it turns the region back into
  459. live code by deleting `C$$$' from the front of each line in it.  The
  460. string used for these comments can be controlled by setting the
  461. variable `fortran-comment-region'.  Note that here we have an example
  462. of a command and a variable with the same name; these two uses of the
  463. name never conflict because in Lisp and in Emacs it is always clear
  464. from the context which one is meant.
  465.  
  466. 
  467. File: emacs,  Node: Fortran Autofill,  Next: Fortran Columns,  Prev: Fortran Comments,  Up: Fortran
  468.  
  469. Fortran Auto Fill Mode
  470. ----------------------
  471.  
  472.    Fortran Auto Fill mode is a minor mode which automatically splits
  473. Fortran statements as you insert them when they become too wide.
  474. Splitting a statement involves making continuation lines.  This
  475. splitting happens when you type SPC, RET, or TAB, and also in the
  476. Fortran indentation commands.
  477.  
  478.    `M-x fortran-auto-fill-mode' turns Fortran Auto Fill mode on if it
  479. was off, or off if it was on.  This command works the same as `M-x
  480. auto-fill-mode' does for normal Auto Fill mode (*note Filling::.).  A
  481. positive numeric argument turns Fortran Auto Fill mode on, and a
  482. negative argument turns it off.  You can see when Fortran Auto Fill mode
  483. is in effect by the presence of the word `Fill' in the mode line,
  484. inside the parentheses.  Fortran Auto Fill mode is a minor mode, turned
  485. on or off for each buffer individually.  *Note Minor Modes::.
  486.  
  487.    Fortran Auto Fill mode breaks lines at spaces or delimiters when the
  488. lines get longer than the desired width (the value of `fill-column').
  489. The delimiters that Fortran Auto Fill mode may break at are `,', `'',
  490. `+', `-', `/', `*', `=', and `)'.  The line break comes after the
  491. delimiter if the variable `fortran-break-before-delimiters' is `nil'.
  492. Otherwise (and by default), the break comes before the delimiter.
  493.  
  494.    By default, Fortran Auto Fill mode is not enabled.  If you want this
  495. feature turned on permanently, add a hook function to
  496. `fortran-mode-hook' to execute `(fortran-auto-fill-mode 1)'.  *Note
  497. Hooks::.
  498.  
  499. 
  500. File: emacs,  Node: Fortran Columns,  Next: Fortran Abbrev,  Prev: Fortran Autofill,  Up: Fortran
  501.  
  502. Columns
  503. -------
  504.  
  505. `C-c C-r'
  506.      Display a "column ruler" momentarily above the current line
  507.      (`fortran-column-ruler').
  508.  
  509. `C-c C-w'
  510.      Split the current window horizontally temporarily so that it is 72
  511.      columns wide.  This may help you avoid making lines longer than
  512.      the 72 character limit that some fortran compilers impose
  513.      (`fortran-window-create-momentarily').
  514.  
  515.    The command `C-c C-r' (`fortran-column-ruler') shows a column ruler
  516. momentarily above the current line.  The comment ruler is two lines of
  517. text that show you the locations of columns with special significance in
  518. Fortran programs.  Square brackets show the limits of the columns for
  519. line numbers, and curly brackets show the limits of the columns for the
  520. statement body.  Column numbers appear above them.
  521.  
  522.    Note that the column numbers count from zero, as always in GNU Emacs.
  523. As a result, the numbers may be one less than those you are familiar
  524. with; but the positions they indicate in the line are standard for
  525. Fortran.
  526.  
  527.    The text used to display the column ruler is the value of the
  528. variable `fortran-comment-ruler'.  By changing this variable, you can
  529. change the display.
  530.  
  531.    For even more help, use `C-c C-w' (`fortran-window-create'), a
  532. command which splits the current window horizontally, making a window 72
  533. columns wide.  By editing in this window you can immediately see when
  534. you make a line too wide to be correct Fortran.
  535.  
  536. 
  537. File: emacs,  Node: Fortran Abbrev,  Prev: Fortran Columns,  Up: Fortran
  538.  
  539. Fortran Keyword Abbrevs
  540. -----------------------
  541.  
  542.    Fortran mode provides many built-in abbrevs for common keywords and
  543. declarations.  These are the same sort of abbrev that you can define
  544. yourself.  To use them, you must turn on Abbrev mode.  *Note Abbrevs::.
  545.  
  546.    The built-in abbrevs are unusual in one way: they all start with a
  547. semicolon.  You cannot normally use semicolon in an abbrev, but Fortran
  548. mode makes this possible by changing the syntax of semicolon to "word
  549. constituent."
  550.  
  551.    For example, one built-in Fortran abbrev is `;c' for `continue'.  If
  552. you insert `;c' and then insert a punctuation character such as a space
  553. or a newline, the `;c' expands automatically to `continue', provided
  554. Abbrev mode is enabled.
  555.  
  556.    Type `;?' or `;C-h' to display a list of all the built-in Fortran
  557. abbrevs and what they stand for.
  558.  
  559. 
  560. File: emacs,  Node: Asm Mode,  Prev: Fortran,  Up: Programs
  561.  
  562. Asm Mode
  563. ========
  564.  
  565.    Asm mode is a major mode for editing files of assembler code.  It
  566. defines these commands:
  567.  
  568. `TAB'
  569.      `tab-to-tab-stop'.
  570.  
  571. `LFD'
  572.      Insert a newline and then indent using `tab-to-tab-stop'.
  573.  
  574. `:'
  575.      Insert a colon and then remove the indentation from before the
  576.      label preceding colon.  Then do `tab-to-tab-stop'.
  577.  
  578. `;'
  579.      Insert or align a comment.
  580.  
  581.    The variable `asm-comment-char' specifies which character starts
  582. comments in assembler syntax.
  583.  
  584. 
  585. File: emacs,  Node: Building,  Next: Abbrevs,  Prev: Programs,  Up: Top
  586.  
  587. Compiling and Testing Programs
  588. ******************************
  589.  
  590.    The previous chapter discusses the Emacs commands that are useful for
  591. making changes in programs.  This chapter deals with commands that
  592. assist in the larger process of developing and maintaining programs.
  593.  
  594. * Menu:
  595.  
  596. * Compilation::                   Compiling programs in languages other
  597.                                     than Lisp (C, Pascal, etc.)
  598. * Debuggers::                      Running symbolic debuggers for
  599.                                     non-Lisp programs.
  600. * Executing Lisp::                Various modes for editing Lisp programs,
  601.                                     with different facilities for running
  602.                                     the Lisp programs.
  603. * Libraries: Lisp Libraries.      Creating Lisp programs to run in Emacs.
  604. * Interaction: Lisp Interaction.  Executing Lisp in an Emacs buffer.
  605. * Eval: Lisp Eval.                Executing a single Lisp expression in Emacs.
  606. * External Lisp::                 Communicating through Emacs with a
  607.                                     separate Lisp.
  608.  
  609. 
  610. File: emacs,  Node: Compilation,  Next: Debuggers,  Up: Building
  611.  
  612. Running `make', or Compilers Generally
  613. ======================================
  614.  
  615.    Emacs can run compilers for noninteractive languages such as C and
  616. Fortran as inferior processes, feeding the error log into an Emacs
  617. buffer.  It can also parse the error messages and show you the source
  618. lines where compilation errors occurred.
  619.  
  620. `M-x compile'
  621.      Run a compiler asynchronously under Emacs, with error messages to
  622.      `*compilation*' buffer.
  623.  
  624. `M-x grep'
  625.      Run `grep' asynchronously under Emacs, with matching lines listed
  626.      in the buffer named `*grep*'.
  627.  
  628. `M-x kill-compilation'
  629. `M-x kill-grep'
  630.      Kill the running compilation or `grep' subprocess.
  631.  
  632. `C-x `'
  633.      Visit the locus of the next compiler error message or `grep' match.
  634.  
  635.    To run `make' or another compilation command, do `M-x compile'.
  636. This command reads a shell command line using the minibuffer, and then
  637. executes the command in an inferior shell, putting output in the buffer
  638. named `*compilation*'.  The current buffer's default directory is used
  639. as the working directory for the execution of the command; normally,
  640. therefore, the compilation happens in this directory.
  641.  
  642.    When the shell command line is read, the minibuffer appears
  643. containing a default command line, which is the command you used the
  644. last time you did `M-x compile'.  If you type just RET, the same command
  645. line is used again.  For the first `M-x compile', the default is `make
  646. -k'.
  647.  
  648.    The default compilation command comes from the variable
  649. `compile-command'; if the appropriate compilation command for a file is
  650. something other than `make -k', it can be useful for the file to
  651. specify a local value for `compile-command' (*note File Variables::.).
  652.  
  653.    Starting a compilation displays the buffer `*compilation*' in
  654. another window but does not select it.  The buffer's mode line tells you
  655. whether compilation is finished, with the word `run' or `exit' inside
  656. the parentheses.  You do not have to keep this buffer visible;
  657. compilation continues in any case.  While a compilation is going on, the
  658. string `Compiling' appears in the mode lines of all windows.  When this
  659. string disappears, the compilation is finished.
  660.  
  661.    To kill the compilation process, do `M-x kill-compilation'.  When
  662. the compiler process terminates, the mode line of the `*compilation*'
  663. buffer changes to say `signal' instead of `run'.  Starting a new
  664. compilation also kills any running compilation, as only one can exist
  665. at any time.  However, `M-x compile' asks for confirmation before
  666. actually killing a compilation that is running.
  667.  
  668.    The `*compilation*' buffer uses a special major mode, Compilation
  669. mode.  This mode provides the keys SPC and DEL to scroll by screenfuls,
  670. and `M-n' and `M-p' to move to the next or previous error message.  You
  671. can also use `M-{' and `M-}' to move up or down to an error message for
  672. a different source file.  You can visit the source for any particular
  673. error message by moving point in `*compilation*' to that error message
  674. and typing `C-c C-c' (`compile-goto-error').
  675.  
  676.    To parse the compiler error messages sequentially, type `C-x `'
  677. (`next-error').  The character following the `C-x' is the backquote or
  678. "grave accent," not the single-quote.  This command is available in all
  679. buffers, not just in `*compilation*'.  It displays the next error
  680. message at the top of one window and source location of the error in
  681. another window.
  682.  
  683.    The first time `C-x `' is used after the start of a compilation, it
  684. moves to the first error's location.  Subsequent uses of `C-x `'
  685. advance down the data set up by the first use.  When the preparsed error
  686. messages are exhausted, the next `C-x `' checks for any more error
  687. messages that have come in; this is useful if you start editing the
  688. compilation errors while the compilation is still going on.  If no more
  689. error messages have come in, `C-x `' reports an error.
  690.  
  691.    `C-u C-x `' discards the preparsed error message data and parses the
  692. `*compilation*' buffer over again, then displaying the first error.
  693. This way, you can process the same set of errors again.
  694.  
  695.    Instead of running a compiler, you can run `grep' and see the lines
  696. on which matches were found.  To do this, type `M-x grep' with an
  697. argument line that contains the same arguments you would give `grep'
  698. when running it normally: a `grep'-style regexp (usually in
  699. single-quotes to quote the shell's special characters) followed by file
  700. names which may use wildcards.  The output from `grep' goes in the
  701. `*grep*' buffer and the lines that matched can be found with `C-x `' as
  702. if they were compilation errors.
  703.  
  704.    Note: a shell is used to run the compile command, but the shell is
  705. told that it should be noninteractive.  This means in particular that
  706. the shell starts up with no prompt.  If you find your usual shell
  707. prompt making an unsightly appearance in the `*compilation*' buffer, it
  708. means you have made a mistake in your shell's init file (`.cshrc' or
  709. `.shrc' or ...) by setting the prompt unconditionally.  The shell init
  710. file should set the prompt only if there already is a prompt.  In
  711. `csh', here is how to do it:
  712.  
  713.      if ($?prompt) set prompt = ...
  714.  
  715. 
  716. File: emacs,  Node: Debuggers,  Next: Executing Lisp,  Prev: Compilation,  Up: Building
  717.  
  718. Running Debuggers Under Emacs
  719. =============================
  720.  
  721.    The GUD (Grand Unified Debugger) library provides an interface to
  722. various symbolic debuggers from within Emacs.  We recommend the debugger
  723. GDB, which is free software, but you can also run DBX, SDB or XDB if you
  724. have them.
  725.  
  726. * Menu:
  727.  
  728. * Starting GUD::    How to start a debugger subprocess.
  729. * Debugger Operation::    Connection between the debugger and source buffers.
  730. * Commands of GUD::    Keybindings for common commands.
  731. * GUD Customization::    Defining your own commands for GUD.
  732.  
  733. 
  734. File: emacs,  Node: Starting GUD,  Next: Debugger Operation,  Up: Debuggers
  735.  
  736. Starting GUD
  737. ------------
  738.  
  739.    There are four commands for starting a debugger, each corresponding
  740. to a particular debugger program.
  741.  
  742. `M-x gdb RET FILE RET'
  743.      Run GDB as a subprocess of Emacs.  This command creates a buffer
  744.      for input and output to GDB, and switches to it.  If a GDB buffer
  745.      already exists, it just switches to that buffer.
  746.  
  747. `M-x dbx RET FILE RET'
  748.      Similar, but run DBX instead of GDB.
  749.  
  750. `M-x xdb RET FILE RET'
  751.      Similar, but run XDB instead of GDB.  Use the variable
  752.      `gud-xdb-directories' to specify directories to search for source
  753.      files.
  754.  
  755. `M-x sdb RET FILE RET'
  756.      Similar, but run SDB instead of GDB.
  757.  
  758.      Some versions of SDB do not mention source file names in their
  759.      messages.  When you use them, you need to have a valid tags table
  760.      (*note Tags::.) in order for GUD to find functions in the source
  761.      code.  If you have not visited a tags table or the tags table
  762.      doesn't list one of the functions, you get a message saying `The
  763.      sdb support requires a valid tags table to work'.  If this
  764.      happens, generate a valid tags table in the working directory and
  765.      try again.
  766.  
  767.    You can only run one debugger process at a time.
  768.  
  769.    Each of these commands takes one argument: a command line to invoke
  770. the debugger.  In the simplest case, specify just the name of the
  771. executable file you want to debug.  You may also use options that the
  772. debugger supports.  However, shell wild cards and variables are not
  773. allowed.  GUD assumes that the first argument not preceded by a `-' is
  774. the executable file name.
  775.  
  776. 
  777. File: emacs,  Node: Debugger Operation,  Next: Commands of GUD,  Prev: Starting GUD,  Up: Debuggers
  778.  
  779. Debugger Operation
  780. ------------------
  781.  
  782.    When you run a debugger with GUD, the debugger uses an Emacs buffer
  783. for its ordinary input and output.  This is called the GUD buffer.  The
  784. debugger uses other Emacs buffers to display the source files of the
  785. program.  An arrow (`=>') in one of these buffers indicates the current
  786. execution line.  Moving point in this buffer does not move the arrow.
  787.  
  788.    You can start editing these source files at any time in the buffers
  789. that were made to display them.  The arrow is not part of the file's
  790. text; it appears only on the screen.  If you do modify a source file,
  791. keep in mind that inserting or deleting lines will throw off the arrow's
  792. positioning; GUD has no way of figuring out which line corresponded
  793. before your changes to the line number in a debugger message.  Also,
  794. you'll typically have to recompile and restart the program for your
  795. changes to be reflected in the debugger's tables.
  796.  
  797.    If you wish, you can control your debugger process entirely through
  798. the debugger buffer, which uses a variant of Shell mode.  All the usual
  799. commands for your debugger are available, and you can use the Shell mode
  800. history commands to repeat them.
  801.  
  802. 
  803. File: emacs,  Node: Commands of GUD,  Next: GUD Customization,  Prev: Debugger Operation,  Up: Debuggers
  804.  
  805. Commands of GUD
  806. ---------------
  807.  
  808.    GUD provides a command available in all buffers for setting
  809. breakpoints.  This command is defined globally because you need to use
  810. it in the source files' buffers.
  811.  
  812. `C-x SPC'
  813.      Set a breakpoint on the line that point is on.
  814.  
  815.    Here are the other commands provided by GUD.  The keys starting with
  816. `C-c' are available only in the GUD interaction buffer.  The bindings
  817. that start with `C-x C-a' are available in the GUD buffer and also in
  818. source files.
  819.  
  820. `C-c C-l'
  821. `C-x C-a C-l'
  822.      Display in another window the last line referred to in the GUD
  823.      buffer (that is, the line indicated in the last location message).
  824.      This runs the command `gud-refresh'.
  825.  
  826. `C-c C-s'
  827. `C-x C-a C-s'
  828.      Execute a single line of code (`gud-step').  If the code contains
  829.      a function call, execution stops after entering the called
  830.      function.
  831.  
  832. `C-c C-n'
  833. `C-x C-a C-n'
  834.      Execute a single line of code, stepping across entire function
  835.      calls at full speed (`gud-next').
  836.  
  837. `C-c C-i'
  838. `C-x C-a C-i'
  839.      Execute a single machine instruction (`gud-stepi').
  840.  
  841. `C-c C-c'
  842. `C-x C-a C-c'
  843.      Continue execution until the next breakpoint, or other event that
  844.      would normally stop the program (`gud-cont').
  845.  
  846. `C-c C-d'
  847. `C-x C-a C-d'
  848.      Delete the breakpoint(s) on the current source line, if any
  849.      (`gud-remove').  If you use this command in the GUD interaction
  850.      buffer, it applies to the line where the program last stopped.
  851.  
  852. `C-c C-t'
  853. `C-x C-a C-t'
  854.      Set a temporary breakpoint on the current source line, if any.  If
  855.      you use this command in the GUD interaction buffer, it applies to
  856.      the line where the program last stopped.
  857.  
  858.    The above commands are common to all supported debuggers.  If you are
  859. using GDB or (some versions of) DBX, these additional commands are
  860. available:
  861.  
  862. `C-c <'
  863. `C-x C-a <'
  864.      Select the next enclosing stack frame (`gud-up').  This is
  865.      equivalent to the `up' command.
  866.  
  867. `C-c >'
  868. `C-x C-a >'
  869.      Select the next inner stack frame (`gud-down').  This is
  870.      equivalent to the `down' command.
  871.  
  872.    If you are using GDB, two additional keybindings are available:
  873.  
  874. `C-c C-f'
  875. `C-x C-a C-f'
  876.      Run the program until the selected stack frame returns (or until it
  877.      stops for some other reason).
  878.  
  879.    These commands interpret a prefix argument as a repeat count, when
  880. that makes sense.
  881.  
  882. 
  883. File: emacs,  Node: GUD Customization,  Prev: Commands of GUD,  Up: Debuggers
  884.  
  885. GUD Customization
  886. -----------------
  887.  
  888.    On startup, GUD runs one of the following hooks: `gdb-mode-hook', if
  889. you are using GDB; `dbx-mode-hook', if you are using DBX;
  890. `sdb-mode-hook', if you are using SDB; and `xdb-mode-hook', if you are
  891. using XDB.  You can use these hooks to define custom keybindings for
  892. the debugger interaction buffer.  *Note Hooks::.
  893.  
  894.    Here is a convenient way to define a command that sends a particular
  895. command string to the debugger, and set up a key binding for it in the
  896. debugger interaction buffer:
  897.  
  898.      (gud-def FUNCTION CMDSTRING BINDING DOCSTRING)
  899.  
  900.    This defines a command named FUNCTION which sends CMDSTRING to the
  901. debugger process, with documentation string DOCSTRING.  You can use the
  902. command thus defined in any buffer.  If BINDING is non-`nil', `gud-def'
  903. also binds the command to `C-c BINDING' in the GUD buffer's mode and to
  904. `C-x C-a BINDING' generally.
  905.  
  906.    The command string CMDSTRING may contain certain escape sequences
  907. that are filled in with varying data at the time FUNCTION is called:
  908.  
  909. `%f'
  910.      Name of the current source file.  If the current buffer is the GUD
  911.      buffer, then the "current source file" is the file that the
  912.      program stopped in.
  913.  
  914. `%l'
  915.      Number of the current source line.  If the current buffer is the
  916.      GUD buffer, then the "current source line" is the line that the
  917.      program stopped in.
  918.  
  919. `%e'
  920.      Text of the C lvalue or function-call expression surrounding point.
  921.  
  922. `%a'
  923.      Text of the hexadecimal address surrounding point.
  924.  
  925. `%p'
  926.      Prefix (numeric) argument of the called function (if any) as a
  927.      number.  (If you don't use `%p' in the command string, the command
  928.      you define ignores any prefix argument.)
  929.  
  930. 
  931. File: emacs,  Node: Executing Lisp,  Next: Lisp Libraries,  Prev: Debuggers,  Up: Building
  932.  
  933. Executing Lisp Expressions
  934. ==========================
  935.  
  936.    Emacs has several different major modes for Lisp and Scheme.  They
  937. are the same in terms of editing commands, but differ in the commands
  938. for executing Lisp expressions.
  939.  
  940. Emacs-Lisp mode
  941.      The mode for editing source files of programs to run in Emacs Lisp.
  942.      This mode defines `C-M-x' to evaluate the current defun.  *Note
  943.      Lisp Libraries::.
  944.  
  945. Lisp Interaction mode
  946.      The mode for an interactive session with Emacs Lisp.  It defines
  947.      LFD to evaluate the sexp before point and insert its value in the
  948.      buffer.  *Note Lisp Interaction::.
  949.  
  950. Lisp mode
  951.      The mode for editing source files of programs that run in Lisps
  952.      other than Emacs Lisp.  This mode defines `C-M-x' to send the
  953.      current defun to an inferior Lisp process.  *Note External Lisp::.
  954.  
  955. Inferior Lisp mode
  956.      The mode for an interactive session with an inferior Lisp process.
  957.      This mode combines the special features of Lisp mode and Shell mode
  958.      (*note Shell Mode::.).
  959.  
  960. Scheme mode
  961.      Like Lisp mode but for Scheme programs.
  962.  
  963. Inferior Scheme mode
  964.      The mode for an interactive session with an inferior Scheme
  965.      process.
  966.  
  967. * Menu:
  968.  
  969. These subnodes of the chapter on editing programs describe the editing
  970. commands for working with Lisp programs, which are in fact available
  971. globally.
  972.  
  973. * Lists::               Expressions with balanced parentheses.
  974. * List Commands::       The commands for working with list and sexps.
  975. * Defuns::              Each program is made up of separate functions.
  976.                           There are editing commands to operate on them.
  977. * Program Indent::      Adjusting indentation to show the nesting.
  978. * Matching::            Insertion of a close-delimiter flashes matching open.
  979. * Comments::            Inserting, killing, and aligning comments.
  980.  
  981. 
  982. File: emacs,  Node: Lisp Libraries,  Next: Lisp Interaction,  Prev: Executing Lisp,  Up: Building
  983.  
  984. Libraries of Lisp Code for Emacs
  985. ================================
  986.  
  987.    Lisp code for Emacs editing commands is stored in files whose names
  988. conventionally end in `.el'.  This ending tells Emacs to edit them in
  989. Emacs-Lisp mode (*note Executing Lisp::.).
  990.  
  991.    To execute a file of Emacs Lisp code, use `M-x load-file'.  This
  992. command reads a file name using the minibuffer and then executes the
  993. contents of that file as Lisp code.  It is not necessary to visit the
  994. file first; in any case, this command reads the file as found on disk,
  995. not text in an Emacs buffer.
  996.  
  997.    Once a file of Lisp code is installed in the Emacs Lisp library
  998. directories, users can load it using `M-x load-library'.  Programs can
  999. load it by calling `load-library', or with `load', a more primitive
  1000. function that is similar but accepts some additional arguments.
  1001.  
  1002.    `M-x load-library' differs from `M-x load-file' in that it searches
  1003. a sequence of directories and tries three file names in each directory.
  1004. Suppose your argument is LIB; the three names are `LIB.elc', `LIB.el',
  1005. and lastly just `LIB'.  If `LIB.elc' exists, it is by convention the
  1006. result of compiling `LIB.el'; it is better to load the compiled file,
  1007. since it will load and run faster.
  1008.  
  1009.    If `load-library' finds that `LIB.el' is newer than `LIB.elc' file,
  1010. it prints a warning, because it's likely that somebody made changes to
  1011. the `.el' file and forgot to recompile it.
  1012.  
  1013.    Because the argument to `load-library' is usually not in itself a
  1014. valid file name, file name completion is not available.  Indeed, when
  1015. using this command, you usually do not know exactly what file name will
  1016. be used.
  1017.  
  1018.    The sequence of directories searched by `M-x load-library' is
  1019. specified by the variable `load-path', a list of strings that are
  1020. directory names.  The default value of the list contains the directory
  1021. where the Lisp code for Emacs itself is stored.  If you have libraries
  1022. of your own, put them in a single directory and add that directory to
  1023. `load-path'.  `nil' in this list stands for the current default
  1024. directory, but it is probably not a good idea to put `nil' in the list.
  1025. If you find yourself wishing that `nil' were in the list, most likely
  1026. what you really want to do is use `M-x load-file' this once.
  1027.  
  1028.    Often you do not have to give any command to load a library, because
  1029. the commands defined in the library are set up to "autoload" that
  1030. library.  Running any of those commands causes `load' to be called to
  1031. load the library; this replaces the autoload definitions with the real
  1032. ones from the library.
  1033.  
  1034.    If autoloading a file does not finish, either because of an error or
  1035. because of a `C-g' quit, all function definitions made by the file are
  1036. undone automatically.  So are any calls to `provide'.  As a consequence,
  1037. if you use one of the autoloadable commands again, the entire file will
  1038. be loaded a second time.  This prevents problems where the command is no
  1039. longer autoloading but it works wrong because not all the file was
  1040. loaded.  Function definitions are undone only for autoloading; explicit
  1041. calls to `load' do not undo anything if loading is not completed.
  1042.  
  1043.    Emacs Lisp code can be compiled into byte-code which loads faster,
  1044. takes up less space when loaded, and executes faster.  *Note Byte
  1045. Compilation: (elisp)Byte Compilation.
  1046.  
  1047.    By convention, the compiled code for a library goes in a separate
  1048. file whose name consists of the library source file with `c' appended.
  1049. Thus, the compiled code for `foo.el' goes in `foo.elc'.  That's why
  1050. `load-library' searches for `.elc' files first.
  1051.  
  1052. 
  1053. File: emacs,  Node: Lisp Eval,  Next: External Lisp,  Prev: Lisp Interaction,  Up: Building
  1054.  
  1055. Evaluating Emacs-Lisp Expressions
  1056. =================================
  1057.  
  1058.    Lisp programs intended to be run in Emacs should be edited in
  1059. Emacs-Lisp mode; this happens automatically for file names ending in
  1060. `.el'.  By contrast, Lisp mode itself is used for editing Lisp programs
  1061. intended for other Lisp systems.  To switch to Emacs-Lisp mode
  1062. explicitly, use the command `M-x emacs-lisp-mode'.
  1063.  
  1064.    For testing of Lisp programs to run in Emacs, it is often useful to
  1065. evaluate part of the program as it is found in the Emacs buffer.  For
  1066. example, after changing the text of a Lisp function definition,
  1067. evaluating the definition installs the change for future calls to the
  1068. function.  Evaluation of Lisp expressions is also useful in any kind of
  1069. editing, for invoking noninteractive functions (functions that are not
  1070. commands).
  1071.  
  1072. `M-ESC'
  1073.      Read a single Lisp expression in the minibuffer, evaluate it, and
  1074.      print the value in the echo area (`eval-expression').
  1075.  
  1076. `C-x C-e'
  1077.      Evaluate the Lisp expression before point, and print the value in
  1078.      the echo area (`eval-last-sexp').
  1079.  
  1080. `C-M-x'
  1081.      Evaluate the defun containing or after point, and print the value
  1082.      in the echo area (`eval-defun').
  1083.  
  1084. `M-x eval-region'
  1085.      Evaluate all the Lisp expressions in the region.
  1086.  
  1087. `M-x eval-current-buffer'
  1088.      Evaluate all the Lisp expressions in the buffer.
  1089.  
  1090.    `M-ESC' (`eval-expression') is the most basic command for evaluating
  1091. a Lisp expression interactively.  It reads the expression using the
  1092. minibuffer, so you can execute any expression on a buffer regardless of
  1093. what the buffer contains.  When the expression is evaluated, the current
  1094. buffer is once again the buffer that was current when `M-ESC' was typed.
  1095.  
  1096.    `M-ESC' can easily confuse users who do not understand it,
  1097. especially on keyboards with autorepeat where it can result from holding
  1098. down the ESC key for too long.  Therefore, `eval-expression' is
  1099. normally a disabled command.  Attempting to use this command asks for
  1100. confirmation and gives you the option of enabling it; once you enable
  1101. the command, confirmation will no longer be required for it.  *Note
  1102. Disabling::.
  1103.  
  1104.    In Emacs-Lisp mode, the key `C-M-x' is bound to the command
  1105. `eval-defun', which parses the defun containing or following point as a
  1106. Lisp expression and evaluates it.  The value is printed in the echo
  1107. area.  This command is convenient for installing in the Lisp environment
  1108. changes that you have just made in the text of a function definition.
  1109.  
  1110.    The command `C-x C-e' (`eval-last-sexp') performs a similar job but
  1111. is available in all major modes, not just Emacs-Lisp mode.  It finds
  1112. the sexp before point, reads it as a Lisp expression, evaluates it, and
  1113. prints the value in the echo area.  It is sometimes useful to type in an
  1114. expression and then, with point still after it, type `C-x C-e'.
  1115.  
  1116.    If `C-M-x' or `C-x C-e' is given a numeric argument, it prints the
  1117. value by insertion into the current buffer at point, rather than in the
  1118. echo area.  The argument value does not matter.
  1119.  
  1120.    The most general command for evaluating Lisp expressions from a
  1121. buffer is `eval-region'.  `M-x eval-region' parses the text of the
  1122. region as one or more Lisp expressions, evaluating them one by one.
  1123. `M-x eval-current-buffer' is similar but evaluates the entire buffer.
  1124. This is a reasonable way to install the contents of a file of Lisp code
  1125. that you are just ready to test.  After finding and fixing a bug, use
  1126. `C-M-x' on each function that you change, to keep the Lisp world in
  1127. step with the source file.
  1128.  
  1129. 
  1130. File: emacs,  Node: Lisp Interaction,  Next: Lisp Eval,  Prev: Lisp Libraries,  Up: Building
  1131.  
  1132. Lisp Interaction Buffers
  1133. ========================
  1134.  
  1135.    The buffer `*scratch*' which is selected when Emacs starts up is
  1136. provided for evaluating Lisp expressions interactively inside Emacs.
  1137.  
  1138.    Thus, the way to use the `*scratch*' buffer is to insert Lisp
  1139. expressions at the end, ending each one with LFD so that it will be
  1140. evaluated.  This command reads the Lisp expression before point,
  1141. evaluates it, and inserts the value in printed representation before
  1142. point.  The result is a complete typescript of the expressions you have
  1143. evaluated and their values.
  1144.  
  1145.    The `*scratch*' buffer's major mode is Lisp Interaction mode, which
  1146. is the same as Emacs-Lisp mode except for the binding of LFD.
  1147.  
  1148.    The rationale for this feature is that Emacs must have a buffer when
  1149. it starts up, but that buffer is not useful for editing files since a
  1150. new buffer is made for every file that you visit.  The Lisp interpreter
  1151. typescript is the most useful thing I can think of for the initial
  1152. buffer to do.  Type `M-x lisp-interaction-mode' to put the current
  1153. buffer in Lisp Interaction mode.
  1154.  
  1155.